﻿using DeHeng_Mes.Model.OrderSingleton;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeHeng_Mes.Model.ProductionSingleton
{
    public class ProductionSingleton
    {
        // 静态只读实例，在静态构造函数中初始化（饿汉式）
        private static readonly List<string> _instance;

        private static readonly object _lock = new object();

        // 静态构造函数：类加载时自动调用，保证线程安全
        static ProductionSingleton()
        {
            _instance = new List<string>();
        }

        // 私有构造函数防止外部实例化
        private ProductionSingleton()
        {

        }

        // 全局访问点（属性形式更符合 C# 习惯）
        public static List<string> Instance => _instance;

        /*public static bool IsSave(string code)
        {
            lock (_lock)
            {
                return _instance.Contains(code);
            }
        }

        public static void Add(string code)
        {
            lock (_lock)
            {
                _instance.Add(code);
            }
        }

        public static void Remove(string code)
        {
            lock (_lock)
            {
                _instance.Remove(code);
            }
        }*/
    }
}
